// src\router\index.ts
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import { track } from "@xmon/bury";
const routes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'index',
    component: () => import('@/views/index/index.vue')
  },
  {
    path: '/home',
    name: 'home',
    component: () => import('@/views/home/index.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/index.vue')
  }
]

const router = createRouter({
  // history: createWebHashHistory(), // hash 路由模式
  history: createWebHistory(), // history 路由模式
  routes // 路由规则
})
router.beforeEach((to, from, next) => {
  // console.log(`router-to`, to)
  // console.log(`router-from`, from)
  // console.log(`router-next`, next)
  const tofrom = track(() => {
    console.log(`to:${to.path},from:${from.path}`);
  }, "routerbefore");
  tofrom();
  next()
})
export default router